package logic

import (
	"context"
	"user_srv/models"
	"user_srv/userclient"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AuthListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAuthListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthListLogic {
	return &AuthListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AuthListLogic) AuthList(in *user.AuthListRequest) (*user.AuthListResponse, error) {
	// todo: add your logic here and delete this line
	var finduser []models.Userldentity
	models.DB.Find(&finduser)
	var userlists []*userclient.AuthList
	for _, userldentity := range finduser {
		list := userclient.AuthList{
			RealName: userldentity.RealName,
			IdCard:   userldentity.IdCard,
			UserId:   userldentity.UserId,
		}
		userlists = append(userlists, &list)
	}

	return &user.AuthListResponse{
		List: userlists,
	}, nil
}
